import torch
from torch import nn
from torch.nn import init 
import numpy as np 
import sys
import torchvision
from torchvision import transforms
from IPython import display
import matplotlib.pyplot as plt
sys.path.append('.')


batch_size=64
mnist_train=torchvision.datasets.FashionMNIST(root='~/Datasets/FashionMNIST',train=True,download=True,transform=transforms.ToTensor())
mnist_test=torchvision.datasets.FashionMNIST(root='~/Datasets/FashionMNIST',train=False,download=True,transform=transforms.ToTensor())


device=torch.device('cuda' if torch.cuda.is_available() else 'cpu') # cuda加速
# print(device)
mnist_train.data.to(device)
mnist_train.targets.to(device)
# mnist_train.class_to_idx.to(device)
# help(mnist_train)
# print(mnist_train.class_to_idx)
# print(mnist_train.data)
mnist_test.data.to(device) # ! 转化为cuda  ，dataset类中 data保存着tensor的原始数据
mnist_test.targets.to(device)
print(mnist_test.data.device)
train_iter=torch.utils.data.DataLoader(mnist_train,pin_memory=True,batch_size=batch_size,shuffle=True,num_workers=8)
test_iter=torch.utils.data.DataLoader(mnist_test,pin_memory=True,batch_size=batch_size,shuffle=True,num_workers=8) # 多线程
